﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/MasterPage.master" AutoEventWireup="true" CodeFile="CompanyDetails.aspx.cs" Inherits="Default2" Title="Фирми" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
    <table  style="border-right: #99ccff thin solid; border-top: #99ccff thin solid; border-left: #99ccff thin solid; border-bottom: #99ccff thin solid" width="100%">
        <tr>
            <td colspan="2">
                <b>РЕГИСТРИРАНЕ НА ФИРМА</b></td>
        </tr>
        <tr>
            <td colspan="2">
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 159px">
                Име на Фирмата:</td>
            <td>
                <asp:TextBox ID="txtCompanyName" runat="server" Width="382px" MaxLength="50" 
                    ValidationGroup="Input"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ControlToValidate="txtCompanyName" 
                    ErrorMessage="* Моля въведете име на фирмата" ValidationGroup="Input"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td style="width: 159px">
                Булстат:</td>
            <td>
                <asp:TextBox ID="txtBulstat" runat="server" Width="382px" MaxLength="15" 
                    ValidationGroup="Input"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                    ControlToValidate="txtBulstat" 
                    ErrorMessage="* Мола въведете БУЛСТАТ на фирмата" ValidationGroup="Input"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td style="width: 159px">
                МОЛ:</td>
            <td>
                <asp:TextBox ID="txtMOL" runat="server" Width="382px" MaxLength="30" 
                    ValidationGroup="Input"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                    ControlToValidate="txtMOL" ErrorMessage="* Мола въведете МОЛ" 
                    ValidationGroup="Input"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td style="width: 159px">
                Град:</td>
            <td>
                <asp:TextBox ID="txtCity" runat="server" Width="206px" MaxLength="30" 
                    ValidationGroup="Input"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                    ControlToValidate="txtCity" ErrorMessage="* Моля въведете Град" 
                    ValidationGroup="Input"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td style="width: 159px">
                Адрес:</td>
            <td>
                <asp:TextBox ID="txtAddress" runat="server" Width="382px" MaxLength="50"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width: 159px">
                Пощенкски Код:</td>
            <td>
                <asp:TextBox ID="txtPostCode" runat="server" Width="66px" MaxLength="6"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width: 159px">
                Телефон:</td>
            <td>
                <asp:TextBox ID="txtPhone" runat="server" Width="204px" MaxLength="15"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width: 159px">
                Адрес за получаване на Фактурите:</td>
            <td>
                <asp:TextBox ID="txtInvoiceAddress" runat="server" Width="383px" MaxLength="80"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <asp:Button ID="btnAddCompany" runat="server" Text="Добави Фирма в Системата" 
                    onclick="btnAddCompany_Click" ValidationGroup="Input" />
&nbsp;
                <input id="btnReset" type="reset" value="Изчисти Полетата" /></td>
        </tr>
    </table>
    <br/>
    <table style="border-right: #99ccff thin solid; border-top: #99ccff thin solid; border-left: #99ccff thin solid; border-bottom: #99ccff thin solid" width="100%">
        <tr>
            <td colspan="2"><b>СПИСЪК С РЕГИСТРИРАНИТЕ ФИРМИ</b></td>
        </tr>
        <tr>
            <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
            <td>
                <asp:GridView ID="gvCompany" runat="server" AllowPaging="True" 
                    AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
                    DataKeyNames="CompanyID" DataSourceID="sdsCompany" ForeColor="#333333" 
                    GridLines="None">
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <Columns>
                        <asp:TemplateField ShowHeader="False">
                            <EditItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                                    CommandName="Update" Text="Обнови"></asp:LinkButton>
                                &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                                    CommandName="Cancel" Text="Прекъсни"></asp:LinkButton>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                                    CommandName="Edit" Text="Редактиране"></asp:LinkButton>
                                &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                                    OnClientClick="return confirm('Желаете ли да изтриете този запис?');" 
                                    CommandName="Delete" Text="Изтриване"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="CompanyName" HeaderText="Фирма" 
                            SortExpression="CompanyName" />
                        <asp:BoundField DataField="BULSTAT" HeaderText="БУЛСТАТ" 
                            SortExpression="BULSTAT" />
                        <asp:BoundField DataField="MOL" HeaderText="МОЛ" SortExpression="MOL" />
                        <asp:BoundField DataField="City" HeaderText="Град" SortExpression="City" />
                        <asp:BoundField DataField="Address" HeaderText="Адрес" 
                            SortExpression="Address" />
                        <asp:BoundField DataField="PostCode" HeaderText="П.Код" 
                            SortExpression="PostCode" />
                        <asp:BoundField DataField="Phone" HeaderText="Телефон" SortExpression="Phone" />
                        <asp:BoundField DataField="InvoiceAddress" HeaderText="Адрес за Фактури" 
                            SortExpression="InvoiceAddress" />
                        <asp:BoundField DataField="Date" HeaderText="Дата" ReadOnly="True" 
                            SortExpression="Date" />
                    </Columns>
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <EmptyDataTemplate>
                        &nbsp;
                    </EmptyDataTemplate>
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <EditRowStyle BackColor="#999999" />
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                </asp:GridView>
          

            </td>
            </tr>
    </table>
          <asp:SqlDataSource ID="sdsCompany" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ClinicConnectionString %>" 
                    DeleteCommand="up_DeleteCompany" DeleteCommandType="StoredProcedure" 
                    InsertCommand="up_CreateCompany" InsertCommandType="StoredProcedure" 
                    SelectCommand="up_GetCompany" SelectCommandType="StoredProcedure" 
                    UpdateCommand="up_UpdateCompany" UpdateCommandType="StoredProcedure">
                    <DeleteParameters>
                        <asp:Parameter Name="companyID" Type="Int32" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="companyID" Type="Int32" />
                        <asp:Parameter Name="companyName" Type="String" />
                        <asp:Parameter Name="bULSTAT" Type="String" />
                        <asp:Parameter Name="mOL" Type="String" />
                        <asp:Parameter Name="city" Type="String" />
                        <asp:Parameter Name="address" Type="String" />
                        <asp:Parameter Name="postCode" Type="String" />
                        <asp:Parameter Name="phone" Type="String" />
                        <asp:Parameter Name="invoiceAddress" Type="String" />
                        <asp:Parameter DefaultValue="" Name="date" Type="DateTime" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:ControlParameter ControlID="txtCompanyName" Name="companyName" 
                            PropertyName="Text" Type="String" />
                        <asp:ControlParameter ControlID="txtBulstat" Name="bULSTAT" PropertyName="Text" 
                            Type="String" />
                        <asp:ControlParameter ControlID="txtMOL" Name="mOL" PropertyName="Text" 
                            Type="String" />
                        <asp:ControlParameter ControlID="txtCity" Name="city" PropertyName="Text" 
                            Type="String" />
                        <asp:ControlParameter ControlID="txtAddress" Name="address" PropertyName="Text" 
                            Type="String" />
                        <asp:ControlParameter ControlID="txtPostCode" Name="postCode" 
                            PropertyName="Text" Type="String" />
                        <asp:ControlParameter ControlID="txtPhone" Name="phone" PropertyName="Text" 
                            Type="String" />
                        <asp:ControlParameter ControlID="txtInvoiceAddress" Name="invoiceAddress" 
                            PropertyName="Text" Type="String" />
                    </InsertParameters>
                </asp:SqlDataSource>
</asp:Content>

